#include <iostream>
#include <cstring>
using namespace std;
const int N = 2010;
int n;
int a[N];
int dp[N];
int main() {
    memset(dp,0x3f3f3f3f,sizeof(dp));
    cin >> n;
    for(int i=1;i<=n;i++) cin >> a[i];
    dp[1]=0;
    for(int i=1;i<n;i++)
    {
        for(int j=1;j<=a[i];j++)
        {
            dp[i+j]=min(dp[i+j],dp[i]+1);
        }
    }
    if(dp[n]<0x3f3f3f3f) cout << dp[n] << endl;
    else cout << -1 << endl;
    return 0;
}